package com.meisupic.copyright.support.security;

import javax.servlet.http.HttpServletRequest;
import org.springframework.security.web.util.matcher.RequestMatcher;
import org.springframework.stereotype.Component;

/**
 * @author lanjian
 * @version V1.0
 * @Description: TODO
 * @date 2018/2/1 0:00
 */
@Component
public class AjaxRequestMatcher implements RequestMatcher {

  /**
   * Decides whether the rule implemented by the strategy matches the supplied request.
   *
   * @param request the request to check for a match
   * @return true if the request matches, false otherwise
   */
  @Override
  public boolean matches(HttpServletRequest request) {
    return "XMLHttpRequest".equals(request.getHeader("X-Requested-With"));
  }
}
